package com.wc.alorithm_luogu.P3156;

import java.io.*;

/**
 * @Author congge
 * @Date 2023/5/14 12:07
 * @description 【深基15.例1】询问学号
 * https://www.luogu.com.cn/problem/P3156
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] array = new int[n + 1];
        for (int i = 1; i <=n ; i++) {
            array[i] = sc.nextInt();
        }

        for (int i = 0; i < m; i++) {
            System.out.println(array[sc.nextInt()]);
        }
    }

    static class Input{
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
